Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FileUploader): expose ref to clear files #18267

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tekno0ryder
Copy link
Contributor

@tekno0ryder tekno0ryder commented Dec 21, 2024

Closes #18223

Clear files in <FileUploader> using ref

Changelog

New

  • Add forward ref to <FileUploader> and expose clearFiles()

Testing / Reviewing

Added temporary story to test the new ref

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 417c206
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/6766fc3d2515600008455628
😎 Deploy Preview https://deploy-preview-18267--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -342,6 +344,6 @@ FileUploader.propTypes = {
* sizes.
*/
size: PropTypes.oneOf(['sm', 'md', 'lg']),
};
} as PropTypes.ValidationMap<FileUploaderProps>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting TS errors and added this as a workaround:

accept: Type '(string | null | undefined)[]' is not assignable to type 'string[]'

filenameStatus: Type 'string' is not assignable to type '"edit" | "complete" | "uploading"'.

@@ -50,38 +50,22 @@ describe('FileUploader', () => {

it('should clear all uploaded files when `clearFiles` is called on a ref', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unit test seems wrong it was trying to test if remove button works. I reverted back to a version from history that actually test clearFiles() function

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 417c206
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6766fc3d6944830008d139e5
😎 Deploy Preview https://deploy-preview-18267--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tekno0ryder tekno0ryder marked this pull request as ready for review December 21, 2024 17:41
@tekno0ryder tekno0ryder requested a review from a team as a code owner December 21, 2024 17:41
Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 417c206
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/6766fc3d3f53850008a3bd14
😎 Deploy Preview https://deploy-preview-18267--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Dec 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.32%. Comparing base (d56c885) to head (417c206).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18267   +/-   ##
=======================================
  Coverage   84.31%   84.32%           
=======================================
  Files         404      404           
  Lines       14359    14360    +1     
  Branches     4606     4606           
=======================================
+ Hits        12107    12109    +2     
+ Misses       2090     2089    -1     
  Partials      162      162           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for doing that!

Copy link
Contributor

@riddhybansal riddhybansal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, This LGTM thanks for contributing and giving detailed explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Allow FileUploader internal files state to be mutated
3 participants